﻿using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using VOL.Entity.DomainModels;
using VOL.Core.Filters;
using System;
using Microsoft.Extensions.Logging;
using Quartz.Logging;
using VoL.Domain.IServices;
using VoL.Domain.IServices.BasicData;
using VOL.WebApi.Common;
using VOL.WebApi.Common.DTO;
using VoL.Domain.IServices.EquipmentManage;
using VoL.Domain.Common.DTO;

namespace VOL.WebApi.Controllers.EquipmentRecord
{
    /// <summary>
    /// 设备记录API控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class EquipmentRecordController : ControllerBase
    {
        /// <summary>
        /// 设备记录服务接口
        /// </summary>
        private readonly IEquipmentRecordServices _equipmentRecordService;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="_equipmentRecordService">设备记录服务接口</param>
        public EquipmentRecordController(IEquipmentRecordServices equipmentRecordService)
        {
            this._equipmentRecordService = equipmentRecordService;
        }

        /// <summary>
        /// 创建/更新设备记录
        /// </summary>
        /// <returns>返回数据</returns>
        [HttpPost] // http://localhost:9991/api/EquipmentRecord/CUEquipmentRecord
        public async Task<APIResult<object>> CUEquipmentRecord([FromBody] EquipmentRecordDTO equipmentRecordDto)
        {
            // 调用服务层方法创建/更新设备记录
            var result = await _equipmentRecordService.CUEquipmentRecord(equipmentRecordDto);
            // 返回结果
            return result;
        }

        /// <summary>
        /// 获取设备记录列表（支持分页和搜索）
        /// </summary>
        [HttpGet]// http://localhost:9991/api/EquipmentRecord/GetEquipmentRecordList
        public async Task<APIResult<PageGridData<EquipmentRecordDTO>>> GetEquipmentRecordList([FromQuery] EquipmentRecordQueryAttribute equipmentRecordQueryAttribute)
        {
            return await _equipmentRecordService.GetEquipmentRecordList(equipmentRecordQueryAttribute);
        }
    }
}
